﻿// Copyright (c) 2011 Blue Onion Software, All rights reserved
using System;

namespace BlueOnionSoftware.Bloget
{
    internal sealed class Throw
    {
        private const string notSpecified = "not specified";

        internal static void IfNull(object arg, string name)
        {
            if (arg == null)
            {
                throw new ArgumentNullException(name ?? notSpecified);
            }
        }

        internal static void IfNullOrEmpty(string arg, string name)
        {
            if (string.IsNullOrEmpty(arg))
            {
                throw (arg == null)
                    ? new ArgumentNullException(name ?? notSpecified)
                    : new ArgumentException("empty", name ?? notSpecified);
            }
        }

        internal static void IfEmpty(Guid guid, string name)
        {
            if (guid == Guid.Empty)
            {
                throw new ArgumentException("empty", name ?? notSpecified);
            }
        }
    }
}